﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;

namespace RootMotion.FinalIK
{
	// Token: 0x02000195 RID: 405
	[HelpURL("https://www.youtube.com/watch?v=r5jiZnsDH3M")]
	[AddComponentMenu("Scripts/RootMotion.FinalIK/Interaction System/Interaction System")]
	public class InteractionSystem : MonoBehaviour
	{
		// Token: 0x0600082D RID: 2093 RVA: 0x0002D0B1 File Offset: 0x0002B4B1
		[ContextMenu("TUTORIAL VIDEO (PART 1: BASICS)")]
		private void OpenTutorial1()
		{
			Application.OpenURL("https://www.youtube.com/watch?v=r5jiZnsDH3M");
		}

		// Token: 0x0600082E RID: 2094 RVA: 0x0002D0BD File Offset: 0x0002B4BD
		[ContextMenu("TUTORIAL VIDEO (PART 2: PICKING UP...)")]
		private void OpenTutorial2()
		{
			Application.OpenURL("https://www.youtube.com/watch?v=eP9-zycoHLk");
		}

		// Token: 0x0600082F RID: 2095 RVA: 0x0002D0C9 File Offset: 0x0002B4C9
		[ContextMenu("TUTORIAL VIDEO (PART 3: ANIMATION)")]
		private void OpenTutorial3()
		{
			Application.OpenURL("https://www.youtube.com/watch?v=sQfB2RcT1T4&index=14&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6");
		}

		// Token: 0x06000830 RID: 2096 RVA: 0x0002D0D5 File Offset: 0x0002B4D5
		[ContextMenu("TUTORIAL VIDEO (PART 4: TRIGGERS)")]
		private void OpenTutorial4()
		{
			Application.OpenURL("https://www.youtube.com/watch?v=-TDZpNjt2mk&index=15&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6");
		}

		// Token: 0x06000831 RID: 2097 RVA: 0x0002D0E1 File Offset: 0x0002B4E1
		[ContextMenu("Support Group")]
		private void SupportGroup()
		{
			Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik");
		}

		// Token: 0x06000832 RID: 2098 RVA: 0x0002D0ED File Offset: 0x0002B4ED
		[ContextMenu("Asset Store Thread")]
		private void ASThread()
		{
			Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/");
		}

		// Token: 0x170000A7 RID: 167
		// (get) Token: 0x06000833 RID: 2099 RVA: 0x0002D0FC File Offset: 0x0002B4FC
		public bool inInteraction
		{
			get
			{
				if (!this.IsValid(true))
				{
					return false;
				}
				for (int i = 0; i < this.interactionEffectors.Length; i++)
				{
					if (this.interactionEffectors[i].inInteraction && !this.interactionEffectors[i].isPaused)
					{
						return true;
					}
				}
				return false;
			}
		}

		// Token: 0x06000834 RID: 2100 RVA: 0x0002D158 File Offset: 0x0002B558
		public bool IsInInteraction(FullBodyBipedEffector effectorType)
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].effectorType == effectorType)
				{
					return this.interactionEffectors[i].inInteraction && !this.interactionEffectors[i].isPaused;
				}
			}
			return false;
		}

		// Token: 0x06000835 RID: 2101 RVA: 0x0002D1C8 File Offset: 0x0002B5C8
		public bool IsPaused(FullBodyBipedEffector effectorType)
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].effectorType == effectorType)
				{
					return this.interactionEffectors[i].inInteraction && this.interactionEffectors[i].isPaused;
				}
			}
			return false;
		}

		// Token: 0x06000836 RID: 2102 RVA: 0x0002D234 File Offset: 0x0002B634
		public bool IsPaused()
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].inInteraction && this.interactionEffectors[i].isPaused)
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x06000837 RID: 2103 RVA: 0x0002D290 File Offset: 0x0002B690
		public bool IsInSync()
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].isPaused)
				{
					for (int j = 0; j < this.interactionEffectors.Length; j++)
					{
						if (j != i && this.interactionEffectors[j].inInteraction && !this.interactionEffectors[j].isPaused)
						{
							return false;
						}
					}
				}
			}
			return true;
		}

		// Token: 0x06000838 RID: 2104 RVA: 0x0002D320 File Offset: 0x0002B720
		public bool StartInteraction(FullBodyBipedEffector effectorType, InteractionObject interactionObject, bool interrupt)
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			if (interactionObject == null)
			{
				return false;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].effectorType == effectorType)
				{
					return this.interactionEffectors[i].Start(interactionObject, this.targetTag, this.fadeInTime, interrupt);
				}
			}
			return false;
		}

		// Token: 0x06000839 RID: 2105 RVA: 0x0002D394 File Offset: 0x0002B794
		public bool PauseInteraction(FullBodyBipedEffector effectorType)
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].effectorType == effectorType)
				{
					return this.interactionEffectors[i].Pause();
				}
			}
			return false;
		}

		// Token: 0x0600083A RID: 2106 RVA: 0x0002D3EC File Offset: 0x0002B7EC
		public bool ResumeInteraction(FullBodyBipedEffector effectorType)
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].effectorType == effectorType)
				{
					return this.interactionEffectors[i].Resume();
				}
			}
			return false;
		}

		// Token: 0x0600083B RID: 2107 RVA: 0x0002D444 File Offset: 0x0002B844
		public bool StopInteraction(FullBodyBipedEffector effectorType)
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].effectorType == effectorType)
				{
					return this.interactionEffectors[i].Stop();
				}
			}
			return false;
		}

		// Token: 0x0600083C RID: 2108 RVA: 0x0002D49C File Offset: 0x0002B89C
		public void PauseAll()
		{
			if (!this.IsValid(true))
			{
				return;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				this.interactionEffectors[i].Pause();
			}
		}

		// Token: 0x0600083D RID: 2109 RVA: 0x0002D4E0 File Offset: 0x0002B8E0
		public void ResumeAll()
		{
			if (!this.IsValid(true))
			{
				return;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				this.interactionEffectors[i].Resume();
			}
		}

		// Token: 0x0600083E RID: 2110 RVA: 0x0002D524 File Offset: 0x0002B924
		public void StopAll()
		{
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				this.interactionEffectors[i].Stop();
			}
		}

		// Token: 0x0600083F RID: 2111 RVA: 0x0002D558 File Offset: 0x0002B958
		public InteractionObject GetInteractionObject(FullBodyBipedEffector effectorType)
		{
			if (!this.IsValid(true))
			{
				return null;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].effectorType == effectorType)
				{
					return this.interactionEffectors[i].interactionObject;
				}
			}
			return null;
		}

		// Token: 0x06000840 RID: 2112 RVA: 0x0002D5B0 File Offset: 0x0002B9B0
		public float GetProgress(FullBodyBipedEffector effectorType)
		{
			if (!this.IsValid(true))
			{
				return 0f;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].effectorType == effectorType)
				{
					return this.interactionEffectors[i].progress;
				}
			}
			return 0f;
		}

		// Token: 0x06000841 RID: 2113 RVA: 0x0002D610 File Offset: 0x0002BA10
		public float GetMinActiveProgress()
		{
			if (!this.IsValid(true))
			{
				return 0f;
			}
			float num = 1f;
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				if (this.interactionEffectors[i].inInteraction)
				{
					float progress = this.interactionEffectors[i].progress;
					if (progress > 0f && progress < num)
					{
						num = progress;
					}
				}
			}
			return num;
		}

		// Token: 0x06000842 RID: 2114 RVA: 0x0002D684 File Offset: 0x0002BA84
		public bool TriggerInteraction(int index, bool interrupt)
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			if (!this.TriggerIndexIsValid(index))
			{
				return false;
			}
			bool result = true;
			InteractionTrigger.Range range = this.triggersInRange[index].ranges[this.bestRangeIndexes[index]];
			for (int i = 0; i < range.interactions.Length; i++)
			{
				for (int j = 0; j < range.interactions[i].effectors.Length; j++)
				{
					if (!this.StartInteraction(range.interactions[i].effectors[j], range.interactions[i].interactionObject, interrupt))
					{
						result = false;
					}
				}
			}
			return result;
		}

		// Token: 0x06000843 RID: 2115 RVA: 0x0002D738 File Offset: 0x0002BB38
		public bool TriggerInteraction(int index, bool interrupt, out InteractionObject interactionObject)
		{
			interactionObject = null;
			if (!this.IsValid(true))
			{
				return false;
			}
			if (!this.TriggerIndexIsValid(index))
			{
				return false;
			}
			bool result = true;
			InteractionTrigger.Range range = this.triggersInRange[index].ranges[this.bestRangeIndexes[index]];
			for (int i = 0; i < range.interactions.Length; i++)
			{
				for (int j = 0; j < range.interactions[i].effectors.Length; j++)
				{
					interactionObject = range.interactions[i].interactionObject;
					if (!this.StartInteraction(range.interactions[i].effectors[j], interactionObject, interrupt))
					{
						result = false;
					}
				}
			}
			return result;
		}

		// Token: 0x06000844 RID: 2116 RVA: 0x0002D7F4 File Offset: 0x0002BBF4
		public bool TriggerInteraction(int index, bool interrupt, out InteractionTarget interactionTarget)
		{
			interactionTarget = null;
			if (!this.IsValid(true))
			{
				return false;
			}
			if (!this.TriggerIndexIsValid(index))
			{
				return false;
			}
			bool result = true;
			InteractionTrigger.Range range = this.triggersInRange[index].ranges[this.bestRangeIndexes[index]];
			for (int i = 0; i < range.interactions.Length; i++)
			{
				for (int j = 0; j < range.interactions[i].effectors.Length; j++)
				{
					InteractionObject interactionObject = range.interactions[i].interactionObject;
					Transform target = interactionObject.GetTarget(range.interactions[i].effectors[j], base.tag);
					if (target != null)
					{
						interactionTarget = target.GetComponent<InteractionTarget>();
					}
					if (!this.StartInteraction(range.interactions[i].effectors[j], interactionObject, interrupt))
					{
						result = false;
					}
				}
			}
			return result;
		}

		// Token: 0x06000845 RID: 2117 RVA: 0x0002D8E4 File Offset: 0x0002BCE4
		public InteractionTrigger.Range GetClosestInteractionRange()
		{
			if (!this.IsValid(true))
			{
				return null;
			}
			int closestTriggerIndex = this.GetClosestTriggerIndex();
			if (closestTriggerIndex < 0 || closestTriggerIndex >= this.triggersInRange.Count)
			{
				return null;
			}
			return this.triggersInRange[closestTriggerIndex].ranges[this.bestRangeIndexes[closestTriggerIndex]];
		}

		// Token: 0x06000846 RID: 2118 RVA: 0x0002D940 File Offset: 0x0002BD40
		public InteractionObject GetClosestInteractionObjectInRange()
		{
			InteractionTrigger.Range closestInteractionRange = this.GetClosestInteractionRange();
			if (closestInteractionRange == null)
			{
				return null;
			}
			return closestInteractionRange.interactions[0].interactionObject;
		}

		// Token: 0x06000847 RID: 2119 RVA: 0x0002D96C File Offset: 0x0002BD6C
		public InteractionTarget GetClosestInteractionTargetInRange()
		{
			InteractionTrigger.Range closestInteractionRange = this.GetClosestInteractionRange();
			if (closestInteractionRange == null)
			{
				return null;
			}
			return closestInteractionRange.interactions[0].interactionObject.GetTarget(closestInteractionRange.interactions[0].effectors[0], this);
		}

		// Token: 0x06000848 RID: 2120 RVA: 0x0002D9AC File Offset: 0x0002BDAC
		public InteractionObject[] GetClosestInteractionObjectsInRange()
		{
			InteractionTrigger.Range closestInteractionRange = this.GetClosestInteractionRange();
			if (closestInteractionRange == null)
			{
				return new InteractionObject[0];
			}
			InteractionObject[] array = new InteractionObject[closestInteractionRange.interactions.Length];
			for (int i = 0; i < closestInteractionRange.interactions.Length; i++)
			{
				array[i] = closestInteractionRange.interactions[i].interactionObject;
			}
			return array;
		}

		// Token: 0x06000849 RID: 2121 RVA: 0x0002DA08 File Offset: 0x0002BE08
		public InteractionTarget[] GetClosestInteractionTargetsInRange()
		{
			InteractionTrigger.Range closestInteractionRange = this.GetClosestInteractionRange();
			if (closestInteractionRange == null)
			{
				return new InteractionTarget[0];
			}
			List<InteractionTarget> list = new List<InteractionTarget>();
			foreach (InteractionTrigger.Range.Interaction interaction in closestInteractionRange.interactions)
			{
				foreach (FullBodyBipedEffector effectorType in interaction.effectors)
				{
					list.Add(interaction.interactionObject.GetTarget(effectorType, this));
				}
			}
			return list.ToArray();
		}

		// Token: 0x0600084A RID: 2122 RVA: 0x0002DA98 File Offset: 0x0002BE98
		public bool TriggerEffectorsReady(int index)
		{
			if (!this.IsValid(true))
			{
				return false;
			}
			if (!this.TriggerIndexIsValid(index))
			{
				return false;
			}
			for (int i = 0; i < this.triggersInRange[index].ranges.Length; i++)
			{
				InteractionTrigger.Range range = this.triggersInRange[index].ranges[i];
				for (int j = 0; j < range.interactions.Length; j++)
				{
					for (int k = 0; k < range.interactions[j].effectors.Length; k++)
					{
						if (this.IsInInteraction(range.interactions[j].effectors[k]))
						{
							return false;
						}
					}
				}
				for (int l = 0; l < range.interactions.Length; l++)
				{
					for (int m = 0; m < range.interactions[l].effectors.Length; m++)
					{
						if (this.IsPaused(range.interactions[l].effectors[m]))
						{
							for (int n = 0; n < range.interactions[l].effectors.Length; n++)
							{
								if (n != m && !this.IsPaused(range.interactions[l].effectors[n]))
								{
									return false;
								}
							}
						}
					}
				}
			}
			return true;
		}

		// Token: 0x0600084B RID: 2123 RVA: 0x0002DBFC File Offset: 0x0002BFFC
		public InteractionTrigger.Range GetTriggerRange(int index)
		{
			if (!this.IsValid(true))
			{
				return null;
			}
			if (index < 0 || index >= this.bestRangeIndexes.Count)
			{
				Warning.Log("Index out of range.", base.transform, false);
				return null;
			}
			return this.triggersInRange[index].ranges[this.bestRangeIndexes[index]];
		}

		// Token: 0x0600084C RID: 2124 RVA: 0x0002DC60 File Offset: 0x0002C060
		public int GetClosestTriggerIndex()
		{
			if (!this.IsValid(true))
			{
				return -1;
			}
			if (this.triggersInRange.Count == 0)
			{
				return -1;
			}
			if (this.triggersInRange.Count == 1)
			{
				return 0;
			}
			int result = -1;
			float num = float.PositiveInfinity;
			for (int i = 0; i < this.triggersInRange.Count; i++)
			{
				if (this.triggersInRange[i] != null)
				{
					float num2 = Vector3.SqrMagnitude(this.triggersInRange[i].transform.position - base.transform.position);
					if (num2 < num)
					{
						result = i;
						num = num2;
					}
				}
			}
			return result;
		}

		// Token: 0x170000A8 RID: 168
		// (get) Token: 0x0600084D RID: 2125 RVA: 0x0002DD13 File Offset: 0x0002C113
		// (set) Token: 0x0600084E RID: 2126 RVA: 0x0002DD1B File Offset: 0x0002C11B
		public FullBodyBipedIK ik
		{
			get
			{
				return this.fullBody;
			}
			set
			{
				this.fullBody = value;
			}
		}

		// Token: 0x170000A9 RID: 169
		// (get) Token: 0x0600084F RID: 2127 RVA: 0x0002DD24 File Offset: 0x0002C124
		// (set) Token: 0x06000850 RID: 2128 RVA: 0x0002DD2C File Offset: 0x0002C12C
		public List<InteractionTrigger> triggersInRange { get; private set; }

		// Token: 0x06000851 RID: 2129 RVA: 0x0002DD38 File Offset: 0x0002C138
		protected virtual void Start()
		{
			if (this.fullBody == null)
			{
				this.fullBody = base.GetComponent<FullBodyBipedIK>();
			}
			if (this.fullBody == null)
			{
				Warning.Log("InteractionSystem can not find a FullBodyBipedIK component", base.transform, false);
				return;
			}
			IKSolverFullBodyBiped solver = this.fullBody.solver;
			solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPreUpdate, new IKSolver.UpdateDelegate(this.OnPreFBBIK));
			IKSolverFullBodyBiped solver2 = this.fullBody.solver;
			solver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver2.OnPostUpdate, new IKSolver.UpdateDelegate(this.OnPostFBBIK));
			this.OnInteractionStart = (InteractionSystem.InteractionDelegate)Delegate.Combine(this.OnInteractionStart, new InteractionSystem.InteractionDelegate(this.LookAtInteraction));
			this.OnInteractionPause = (InteractionSystem.InteractionDelegate)Delegate.Combine(this.OnInteractionPause, new InteractionSystem.InteractionDelegate(this.InteractionPause));
			this.OnInteractionResume = (InteractionSystem.InteractionDelegate)Delegate.Combine(this.OnInteractionResume, new InteractionSystem.InteractionDelegate(this.InteractionResume));
			this.OnInteractionStop = (InteractionSystem.InteractionDelegate)Delegate.Combine(this.OnInteractionStop, new InteractionSystem.InteractionDelegate(this.InteractionStop));
			foreach (InteractionEffector interactionEffector in this.interactionEffectors)
			{
				interactionEffector.Initiate(this);
			}
			this.triggersInRange = new List<InteractionTrigger>();
			this.c = base.GetComponent<Collider>();
			this.UpdateTriggerEventBroadcasting();
			this.initiated = true;
		}

		// Token: 0x06000852 RID: 2130 RVA: 0x0002DEAF File Offset: 0x0002C2AF
		private void InteractionPause(FullBodyBipedEffector effector, InteractionObject interactionObject)
		{
			this.lookAt.isPaused = true;
		}

		// Token: 0x06000853 RID: 2131 RVA: 0x0002DEBD File Offset: 0x0002C2BD
		private void InteractionResume(FullBodyBipedEffector effector, InteractionObject interactionObject)
		{
			this.lookAt.isPaused = false;
		}

		// Token: 0x06000854 RID: 2132 RVA: 0x0002DECB File Offset: 0x0002C2CB
		private void InteractionStop(FullBodyBipedEffector effector, InteractionObject interactionObject)
		{
			this.lookAt.isPaused = false;
		}

		// Token: 0x06000855 RID: 2133 RVA: 0x0002DED9 File Offset: 0x0002C2D9
		private void LookAtInteraction(FullBodyBipedEffector effector, InteractionObject interactionObject)
		{
			this.lookAt.Look(interactionObject.lookAtTarget, Time.time + interactionObject.length * 0.5f);
		}

		// Token: 0x06000856 RID: 2134 RVA: 0x0002DF00 File Offset: 0x0002C300
		public void OnTriggerEnter(Collider c)
		{
			if (this.fullBody == null)
			{
				return;
			}
			InteractionTrigger component = c.GetComponent<InteractionTrigger>();
			if (this.inContact.Contains(component))
			{
				return;
			}
			this.inContact.Add(component);
		}

		// Token: 0x06000857 RID: 2135 RVA: 0x0002DF44 File Offset: 0x0002C344
		public void OnTriggerExit(Collider c)
		{
			if (this.fullBody == null)
			{
				return;
			}
			InteractionTrigger component = c.GetComponent<InteractionTrigger>();
			this.inContact.Remove(component);
		}

		// Token: 0x06000858 RID: 2136 RVA: 0x0002DF78 File Offset: 0x0002C378
		private bool ContactIsInRange(int index, out int bestRangeIndex)
		{
			bestRangeIndex = -1;
			if (!this.IsValid(true))
			{
				return false;
			}
			if (index < 0 || index >= this.inContact.Count)
			{
				Warning.Log("Index out of range.", base.transform, false);
				return false;
			}
			if (this.inContact[index] == null)
			{
				Warning.Log("The InteractionTrigger in the list 'inContact' has been destroyed", base.transform, false);
				return false;
			}
			bestRangeIndex = this.inContact[index].GetBestRangeIndex(base.transform, this.FPSCamera, this.raycastHit);
			return bestRangeIndex != -1;
		}

		// Token: 0x06000859 RID: 2137 RVA: 0x0002E01C File Offset: 0x0002C41C
		private void OnDrawGizmosSelected()
		{
			if (Application.isPlaying)
			{
				return;
			}
			if (this.fullBody == null)
			{
				this.fullBody = base.GetComponent<FullBodyBipedIK>();
			}
			if (this.characterCollider == null)
			{
				this.characterCollider = base.GetComponent<Collider>();
			}
		}

		// Token: 0x0600085A RID: 2138 RVA: 0x0002E070 File Offset: 0x0002C470
		private void Update()
		{
			if (this.fullBody == null)
			{
				return;
			}
			this.UpdateTriggerEventBroadcasting();
			this.Raycasting();
			this.triggersInRange.Clear();
			this.bestRangeIndexes.Clear();
			for (int i = 0; i < this.inContact.Count; i++)
			{
				int item = -1;
				if (this.inContact[i] != null && this.inContact[i].gameObject.activeInHierarchy && this.inContact[i].enabled && this.ContactIsInRange(i, out item))
				{
					this.triggersInRange.Add(this.inContact[i]);
					this.bestRangeIndexes.Add(item);
				}
			}
			this.lookAt.Update();
		}

		// Token: 0x0600085B RID: 2139 RVA: 0x0002E154 File Offset: 0x0002C554
		private void Raycasting()
		{
			if (this.camRaycastLayers == -1)
			{
				return;
			}
			if (this.FPSCamera == null)
			{
				return;
			}
			Physics.Raycast(this.FPSCamera.position, this.FPSCamera.forward, out this.raycastHit, this.camRaycastDistance, this.camRaycastLayers);
		}

		// Token: 0x0600085C RID: 2140 RVA: 0x0002E1B8 File Offset: 0x0002C5B8
		private void UpdateTriggerEventBroadcasting()
		{
			if (this.characterCollider == null)
			{
				this.characterCollider = this.c;
			}
			if (this.characterCollider != null && this.characterCollider != this.c)
			{
				if (this.characterCollider.GetComponent<TriggerEventBroadcaster>() == null)
				{
					TriggerEventBroadcaster triggerEventBroadcaster = this.characterCollider.gameObject.AddComponent<TriggerEventBroadcaster>();
					triggerEventBroadcaster.target = base.gameObject;
				}
				if (this.lastCollider != null && this.lastCollider != this.c && this.lastCollider != this.characterCollider)
				{
					TriggerEventBroadcaster component = this.lastCollider.GetComponent<TriggerEventBroadcaster>();
					if (component != null)
					{
						UnityEngine.Object.Destroy(component);
					}
				}
			}
			this.lastCollider = this.characterCollider;
		}

		// Token: 0x0600085D RID: 2141 RVA: 0x0002E2A4 File Offset: 0x0002C6A4
		private void LateUpdate()
		{
			if (this.fullBody == null)
			{
				return;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				this.interactionEffectors[i].Update(base.transform, this.speed);
			}
			for (int j = 0; j < this.interactionEffectors.Length; j++)
			{
				this.interactionEffectors[j].ResetToDefaults(this.resetToDefaultsSpeed * this.speed);
			}
		}

		// Token: 0x0600085E RID: 2142 RVA: 0x0002E329 File Offset: 0x0002C729
		private void OnPreFBBIK()
		{
			if (!base.enabled)
			{
				return;
			}
			if (this.fullBody == null)
			{
				return;
			}
			this.lookAt.SolveSpine();
		}

		// Token: 0x0600085F RID: 2143 RVA: 0x0002E354 File Offset: 0x0002C754
		private void OnPostFBBIK()
		{
			if (!base.enabled)
			{
				return;
			}
			if (this.fullBody == null)
			{
				return;
			}
			for (int i = 0; i < this.interactionEffectors.Length; i++)
			{
				this.interactionEffectors[i].OnPostFBBIK();
			}
			this.lookAt.SolveHead();
		}

		// Token: 0x06000860 RID: 2144 RVA: 0x0002E3B0 File Offset: 0x0002C7B0
		private void OnDestroy()
		{
			if (this.fullBody == null)
			{
				return;
			}
			IKSolverFullBodyBiped solver = this.fullBody.solver;
			solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPreUpdate, new IKSolver.UpdateDelegate(this.OnPreFBBIK));
			IKSolverFullBodyBiped solver2 = this.fullBody.solver;
			solver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver2.OnPostUpdate, new IKSolver.UpdateDelegate(this.OnPostFBBIK));
			this.OnInteractionStart = (InteractionSystem.InteractionDelegate)Delegate.Remove(this.OnInteractionStart, new InteractionSystem.InteractionDelegate(this.LookAtInteraction));
			this.OnInteractionPause = (InteractionSystem.InteractionDelegate)Delegate.Remove(this.OnInteractionPause, new InteractionSystem.InteractionDelegate(this.InteractionPause));
			this.OnInteractionResume = (InteractionSystem.InteractionDelegate)Delegate.Remove(this.OnInteractionResume, new InteractionSystem.InteractionDelegate(this.InteractionResume));
			this.OnInteractionStop = (InteractionSystem.InteractionDelegate)Delegate.Remove(this.OnInteractionStop, new InteractionSystem.InteractionDelegate(this.InteractionStop));
		}

		// Token: 0x06000861 RID: 2145 RVA: 0x0002E4B0 File Offset: 0x0002C8B0
		private bool IsValid(bool log)
		{
			if (this.fullBody == null)
			{
				if (log)
				{
					Warning.Log("FBBIK is null. Will not update the InteractionSystem", base.transform, false);
				}
				return false;
			}
			if (!this.initiated)
			{
				if (log)
				{
					Warning.Log("The InteractionSystem has not been initiated yet.", base.transform, false);
				}
				return false;
			}
			return true;
		}

		// Token: 0x06000862 RID: 2146 RVA: 0x0002E50C File Offset: 0x0002C90C
		private bool TriggerIndexIsValid(int index)
		{
			if (index < 0 || index >= this.triggersInRange.Count)
			{
				Warning.Log("Index out of range.", base.transform, false);
				return false;
			}
			if (this.triggersInRange[index] == null)
			{
				Warning.Log("The InteractionTrigger in the list 'inContact' has been destroyed", base.transform, false);
				return false;
			}
			return true;
		}

		// Token: 0x06000863 RID: 2147 RVA: 0x0002E56F File Offset: 0x0002C96F
		[ContextMenu("User Manual")]
		private void OpenUserManual()
		{
			Application.OpenURL("http://www.root-motion.com/finalikdox/html/page10.html");
		}

		// Token: 0x06000864 RID: 2148 RVA: 0x0002E57B File Offset: 0x0002C97B
		[ContextMenu("Scrpt Reference")]
		private void OpenScriptReference()
		{
			Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_interaction_system.html");
		}

		// Token: 0x04000526 RID: 1318
		[Tooltip("If not empty, only the targets with the specified tag will be used by this Interaction System.")]
		public string targetTag = string.Empty;

		// Token: 0x04000527 RID: 1319
		[Tooltip("The fade in time of the interaction.")]
		public float fadeInTime = 0.3f;

		// Token: 0x04000528 RID: 1320
		[Tooltip("The master speed for all interactions.")]
		public float speed = 1f;

		// Token: 0x04000529 RID: 1321
		[Tooltip("If > 0, lerps all the FBBIK channels used by the Interaction System back to their default or initial values when not in interaction.")]
		public float resetToDefaultsSpeed = 1f;

		// Token: 0x0400052A RID: 1322
		[Header("Triggering")]
		[Tooltip("The collider that registers OnTriggerEnter and OnTriggerExit events with InteractionTriggers.")]
		[FormerlySerializedAs("collider")]
		public Collider characterCollider;

		// Token: 0x0400052B RID: 1323
		[Tooltip("Will be used by Interaction Triggers that need the camera's position. Assign the first person view character camera.")]
		[FormerlySerializedAs("camera")]
		public Transform FPSCamera;

		// Token: 0x0400052C RID: 1324
		[Tooltip("The layers that will be raycasted from the camera (along camera.forward). All InteractionTrigger look at target colliders should be included.")]
		public LayerMask camRaycastLayers;

		// Token: 0x0400052D RID: 1325
		[Tooltip("Max distance of raycasting from the camera.")]
		public float camRaycastDistance = 1f;

		// Token: 0x0400052F RID: 1327
		private List<InteractionTrigger> inContact = new List<InteractionTrigger>();

		// Token: 0x04000530 RID: 1328
		private List<int> bestRangeIndexes = new List<int>();

		// Token: 0x04000531 RID: 1329
		public InteractionSystem.InteractionDelegate OnInteractionStart;

		// Token: 0x04000532 RID: 1330
		public InteractionSystem.InteractionDelegate OnInteractionPause;

		// Token: 0x04000533 RID: 1331
		public InteractionSystem.InteractionDelegate OnInteractionPickUp;

		// Token: 0x04000534 RID: 1332
		public InteractionSystem.InteractionDelegate OnInteractionResume;

		// Token: 0x04000535 RID: 1333
		public InteractionSystem.InteractionDelegate OnInteractionStop;

		// Token: 0x04000536 RID: 1334
		public InteractionSystem.InteractionEventDelegate OnInteractionEvent;

		// Token: 0x04000537 RID: 1335
		public RaycastHit raycastHit;

		// Token: 0x04000538 RID: 1336
		[Space(10f)]
		[Tooltip("Reference to the FBBIK component.")]
		[SerializeField]
		private FullBodyBipedIK fullBody;

		// Token: 0x04000539 RID: 1337
		[Tooltip("Handles looking at the interactions.")]
		public InteractionLookAt lookAt = new InteractionLookAt();

		// Token: 0x0400053A RID: 1338
		private InteractionEffector[] interactionEffectors = new InteractionEffector[]
		{
			new InteractionEffector(FullBodyBipedEffector.Body),
			new InteractionEffector(FullBodyBipedEffector.LeftFoot),
			new InteractionEffector(FullBodyBipedEffector.LeftHand),
			new InteractionEffector(FullBodyBipedEffector.LeftShoulder),
			new InteractionEffector(FullBodyBipedEffector.LeftThigh),
			new InteractionEffector(FullBodyBipedEffector.RightFoot),
			new InteractionEffector(FullBodyBipedEffector.RightHand),
			new InteractionEffector(FullBodyBipedEffector.RightShoulder),
			new InteractionEffector(FullBodyBipedEffector.RightThigh)
		};

		// Token: 0x0400053B RID: 1339
		private bool initiated;

		// Token: 0x0400053C RID: 1340
		private Collider lastCollider;

		// Token: 0x0400053D RID: 1341
		private Collider c;

		// Token: 0x02000196 RID: 406
		// (Invoke) Token: 0x06000866 RID: 2150
		public delegate void InteractionDelegate(FullBodyBipedEffector effectorType, InteractionObject interactionObject);

		// Token: 0x02000197 RID: 407
		// (Invoke) Token: 0x0600086A RID: 2154
		public delegate void InteractionEventDelegate(FullBodyBipedEffector effectorType, InteractionObject interactionObject, InteractionObject.InteractionEvent interactionEvent);
	}
}
